function smaller(nums) {
    return nums.map((v, i) => nums.slice(i + 1).filter(x => v < v).length)
}

smaller([1, 2, 3])

console.log(18 ** 3)